package java05;

import java.util.*;
import java.util.Map.Entry;

public class Java53 {

	public static void main(String[] args) {
		Map<String,Integer> map = new HashMap<String,Integer>();
        Scanner in = new Scanner(System.in);
        while(in.hasNext()){
            String str = in.next();
            if(str.equals("!!!!!"))
                break;
            if(!map.containsKey(str)){
            	map.put(str,1);
            }
            else{
            	int key = map.get(str);
            	map.put(str,key+1);
            }
        }
        System.out.println(map.size());
        List<Map.Entry<String,Integer>> list = new ArrayList<Map.Entry<String,Integer>>(map.entrySet());
        Collections.sort(list,new Comparator<Map.Entry<String,Integer>>() {
            public int compare(Entry<String, Integer> o1,Entry<String, Integer> o2) {
            	int b = o2.getValue()-o1.getValue();
            	if(b!=0)
            		return b;
            	else
            		return o1.getKey().compareTo(o2.getKey());
            }
        });
        for (Entry<String, Integer> entry : list.subList(0, 10)) {
        	System.out.println(entry.getKey()+"="+entry.getValue());
		}
	}
}
